/* eslint-disable no-unused-vars */
import Vue from 'vue'
import VueRouter from 'vue-router'

import Welcome from '../components/Welcome.vue'
import Login from '../components/Login.vue'
import Regisiter from '../components/Register.vue'
import ForgotPassword from '../components/ForgotPassword.vue'
import ResetPassword from '../components/ResetPassword.vue'
import Home from '../components/Home.vue'
import Explore from '../components/Explore.vue'
import HomeWorkList from '../components/HomeWorkList.vue'
import UserCenter from '../components/UserCenter.vue'
import profile from '../components/profile.vue'
// eslint-disable-next-line no-unused-vars
import passwordCheck from '../components/passwordCheck.vue'
import mailCheck from '../components/mailCheck.vue'
import mailReset from '../components/mailReset.vue'
import messageCenter from '../components/messageCenter.vue'
import Details from '../components/Details.vue'
import Search from '../components/Search.vue'
import Admin from '../components/Admin.vue'
import CheckWork from '../components/CheckWork.vue'
import CheckDetails from '../components/CheckDetails.vue'
import CheckAppeal from '../components/CheckAppeal.vue'
import AppealDetails from '../components/AppealDetails.vue'
Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    // 重定向规则：用户访问根目录自动进入welcome登录页面
    { path: '/', redirect: '/welcome' },
    // { path: '/welcome', component: Welcome },
    {
      path: '/welcome',
      component: Welcome,
      redirect: '/login',
      children: [
        { path: '/login', component: Login },
        // { path: '/search/:id/:type/:name', component: Search }
        { path: '/tourist/search/:type/:name', component: Search },
        { path: '/tourist/details/:type/:fileId', component: Details }
      ]
    },
    { path: '/register', component: Regisiter },
    { path: '/ForgotPassword', component: ForgotPassword },
    { path: '/ResetPassword/:id', component: ResetPassword },
    {
      path: '/home/:id',
      component: Home,
      redirect: '/homework/:id',
      children: [
        { path: '/homework/:id', component: HomeWorkList },
        // { path: '/homework/123testuserid', component: HomeWorkList }, // mockjs测试接口使用的路由,连接后端用上面那个
        { path: '/explore/:id', component: Explore },
        {
          path: '/userCenter/:id',
          component: UserCenter,
          redirect: '/userCenter/profile/:id',
          children: [
            { path: '/userCenter/profile/:id', component: profile },
            // { path: '/userCenter/passwordCheck/:id', component: r => require.ensure([], () => r(require('@/components/profile')), 'demo') },
            { path: '/userCenter/passwordCheck/:id', component: r => require.ensure([], () => r(require('@/components/passwordCheck')), 'demo') },
            { path: '/userCenter/mailCheck/:id', component: r => require.ensure([], () => r(require('@/components/mailCheck')), 'demo') },
            { path: '/userCenter/passwordCheck/:id', component: r => require.ensure([], () => r(require('@/components/mailReset')), 'demo') },
            // { path: '/userCenter/mailCheck/:id', component: r => require.ensure([], () => r(require('@/components/messageCenter')), 'demo') }
            { path: '/userCenter/mailReset/:id', component: mailReset },
            { path: '/userCenter/messageCenter/:id', component: messageCenter }
          ]
        },
        { path: '/messageCenter/:id', component: messageCenter },
        // { path: '/details/:type/:fileId', component: Details },
        { path: '/details/:id/:type/:fileId', component: Details },
        { path: '/home/:id/search/:type/:name', component: Search }
      ]
    },
    {
      path: '/admin/:id',
      component: Admin,
      redirect: '/checkwork/:id',
      children: [
        { path: '/checkwork/:id', component: CheckWork },
        { path: '/checkappeal/:id', component: CheckAppeal },
        { path: '/checkdetails/:id/:type/:fileId', component: CheckDetails },
        { path: '/appealdetails/:id/:type/:fileId', component: AppealDetails },
        { path: '/admin/:id/search/:type/:name', component: Search }
        // { path: '/admin/search/:type/:name', component: Search },
        // { path: '/admin/details/:type/:fileId', component: Details }
      ]
    }
  ]
})

export default router
